<template>
  <div>
    <a-card :bordered="false">
      <f-search-form :more="false" :table-obj="$refs.table">
        <f-search-form-item label="店铺名称" name="shopName"/>
        <f-search-form-item label="联系人" name="linkMan"/>
        <f-search-form-item label="认证状态" name="shopState" type="select" :data="api.shop.shopStatus2"></f-search-form-item>
      </f-search-form>
      <f-table ref="table" size="default" rowKey="shopId" :columns="columns" :multiple="false" :operator="operator" :params="queryParam" :api="api.shop">
        <span slot="shopLogo" slot-scope="text, record, index">
          <img :src="record.shopLogo" alt="" width="40" height="40" class="radius-img">
        </span>
        <span slot="shopState" slot-scope="text, record, index">
            <a-tag color="#108ee9" v-if="text==0">未认证</a-tag>
            <a-tag color="#108ee9" v-if="text==10">未审核</a-tag>
            <a-tag color="#87d068" v-if="text==1">已审核</a-tag>
            <a-tag color="#f50" v-if="text==2">审核失败</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">
          <template>
            <a @click="$refs.modal.handleShow(record)">编辑</a>
            <a-divider type="vertical"/>
          </template>
          <a-dropdown>
            <a class="ant-dropdown-link">
              更多 <a-icon type="down"/>
            </a>
            <a-menu slot="overlay">
              <a-menu-item v-if="$auth('table.delete')">
                <a href="javascript:;" @click="$refs.table.remove(record.shopId)">删除</a>
              </a-menu-item>
            </a-menu>
          </a-dropdown>
        </span>
      </f-table>
      <shop-drawer ref="modal"></shop-drawer>
      <shop-audit ref="shopAudit"></shop-audit>
    </a-card>
  </div>
</template>

<script>


  import ShopDrawer from './shop_drawer'

  export default {
    name: 'TableList',
    components: {
      ShopDrawer,
      ShopAudit: resolve => {
        require(['./shop_audit.vue'], resolve)
      }
    },
    data () {
      let me = this
      return {
        //列表初始化查询参数
        queryParam: {},
        // 表头
        columns: [
          {
            title: '店铺Logo',
            align: 'center',
            scopedSlots: { customRender: 'shopLogo' }
          },
          {
            title: '店铺名称',
            dataIndex: 'shopName'
          },
          {
            title: '联系人',
            dataIndex: 'linkMan'
          },
          {
            title: '联系电话',
            width: 100,
            dataIndex: 'linkTel'
          },
          {
            title: '店铺地址',
            dataIndex: 'shopAddress'
          },
          {
            title: '认证状态',
            align: 'center',
            dataIndex: 'shopState',
            scopedSlots: { customRender: 'shopState' }
          },
          {
            title: '操作',
            dataIndex: 'action',
            width: '180px',
            scopedSlots: { customRender: 'action' }
          }
        ],
        //操作按钮
        operator: [

          {
            name: '删除',
            icon: 'delete',
            batch: true,
            handler: function (table) {
              table.remove()
            }
          }
        ]
      }
    },
    created () {

    },
    methods: {
      setStatus (check, record) {
        this.http.post(this, {
          url: this.api.shop.setRecommend,
          data: {
            ids: record.shopId,
            recommend: Number(check)
          },
          success (me, data) {
            record.recommend = data
          }
        })
      }
    }
  }
</script>
